<script type="text/javascript">
	
/*	set */
function fun1(arr) {
	let set = new Set();
	for(let i = 0; i < arr.length; i++) {
		if(arr[i] instanceof Array) {
			set.add(...arr[i]);
		} else {
			set.add(arr[i]);
		}
	}
	return [...set];
}
let res = fun1([1, 2, [2, 1], 3]);
console.log(res)

</script>